home *** CD-ROM | disk | FTP | other *** search
- Path: news.ahc.ameritech.com!datalytics!news
- From: Rob Stewart <stew@datalytics.com>
- Newsgroups: comp.lang.c++
- Subject: Re: Faster FILE subroutines in standard C?
- Date: 8 Jan 1996 17:45:32 GMT
- Organization: Datalytics, Inc
- Message-ID: <4crl7s$h4r@gold.datalytics.com>
- References: <4cflbt$d4h@sunburst.ccs.yorku.ca> <4cges0$kqi@news1.usa.pipeline.com>
- NNTP-Posting-Host: pc071.datalytics.com
- Mime-Version: 1.0
- Content-Type: text/plain; charset=us-ascii
- Content-Transfer-Encoding: 7bit
- X-Mailer: Mozilla 1.22 (Windows; I; 32bit)
-
- grantp@usa.pipeline.com(Pete) wrote:
- >On Jan 04, 1996 04:34:05 in article <Re: Faster FILE subroutines in
- >standard C?>, 'ken@yorku.ca (Kenneth Kafieh)' wrote:
- >
- >>Ken (ken@afep.yorku.ca) wrote:
- >>
- >>: I found that I was able to get 3-4 time faster performance by using good
- >
- >>: old ANSI C file accessing routines (like fgets, fseek, ftell, ...etc.)
- >>: instead of C++ streams (like ifstream::getline, fstream::seekg, ...etc.)
- >
-
- [snip]
-
- >>: Does that sound right?
- >
- >No.
- >
- >>: Maybe my code was inefficiently written?
- >
- >That would be my guess -- given the difference.
- >
-
- Writing good code for the iostreams library is difficult; the
- iostreams code may have been inefficient.
-
- >>: I know C++ is generally slower than C but I didn't think that
- >
- >Why do you say that?
- >
-
- C++ is not slower than C on the same code. It's that C++
- makes it easier to do things than they were in C, so we tend
- to do fancier things (behind the scenes, anyway). So long as
- you don't take advantage of any of the features of C++ that
- would make your code slower, you wouldn't see any difference.
- (Don't forget that every C++ compiler also compiles C code.)
-
- As soon as you make use of virtual base classes, polymorphism,
- etc., your code runs slower. The advantage is type safety,
- flexibility, and ease of expression. There are always
- tradeoffs to be made.
-
- [snip]
-
- >>
- >I wouldn't place too much value in the results of an old
- >implementation of a library. BC20 was released about five years
- >ago so its performace is really not applicable today.
- >
- >I haven't performed actual tests; however, with today's compiler
- >systems there is a negligible apparent difference (if any)
- >between stdio and iostreams -- at least in the applications
- >I've converted from one to the other.
- >
-
- The iostreams library is slower than the stdio stuff, though
- perhaps not by a large margin anymore. That's not the point.
- The point of iostreams was a demonstration of multiple
- inheritance. As a benefit, it provided a simplified, typesafe
- form of file I/O.
-
- --
- Robert Stewart | My opinions are usually my own.
- Datalytics, Inc.
- (513)226-7700
- stew@datalytics.com
-
-
-